# @Author: Zhixuan.Wang
# @IDE: PyCharm
# @Project: multimodal
# @File: Correct_XML_Name.py
# @Time: 2025/11/7 16:31
# @Description: 将xml文件名称格式化

import os
import shutil

Annotation_Path = r"D:\LungCancer\VOCdevkit\VOC2012\Annotations"
Taeget_Path = r"D:\LungCancer\VOCdevkit\VOC2012\NEW-Annotations"

for xml in os.listdir(Annotation_Path):
    xml_path = os.path.join(Annotation_Path, xml)
    # 重塑xml文件名称
    new_xml = os.path.splitext(xml)[0].split('_')[0] + os.path.splitext(xml)[1]
    # 指定存储路径
    target_path = os.path.join(Taeget_Path, new_xml)
    # 将原路径下的图片复制到目标路径下
    shutil.copy2(xml_path, target_path)

print("Completed!")
